package com.zac.coroutine.algorithm.leetcode.linkedlist;

/**
 * author zac
 * date 2024/12/25
 */
public class Test1 {

    public static void main(String[] args) {

    }

    public boolean hasCycle(ListNode head) {

        if (head == null || head.next == null) return false;
        ListNode node = head;
        while (true) {
            if (node.next == null) {
                return false;
            }

            ListNode cur = node.next;
            ListNode t = head;
            while (t != cur.next) {
                if (cur == t) {
                    return true;
                }
                t = t.next;
            }
            node = node.next;

        }

    }
}
